home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 March / Macworld CD-ROM (March 1995).cdr / Updaters / AppMaker 1.5.2->1.5.4 / Libraries / THINK / AMClassLibC / CAMDialogDirector.cp < prev    next >
Encoding:
Text File  |  1993-05-24  |  3.1 KB  |  113 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CAMDialogDirector.c
  3.  
  4.                             The AMDialogDirector Class
  5.         
  6.     
  7.     SUPERCLASS = CDialogDirector
  8.     
  9.  ******************************************************************************/
  10.  
  11. #include <CDialog.h>
  12. #include <Commands.h>
  13. #include <Dialogs.h>
  14. #include "CAMDialogDirector.h"
  15.  
  16. extern struct CDesktop    *gDesktop;
  17.  
  18. /******************************************************************************
  19.  IAMDialogDirector
  20.  
  21.         Initialize a CAMDialogDirector object
  22.  ******************************************************************************/
  23.  
  24. void    CAMDialogDirector::IAMDialogDirector     (short            dialogID,    
  25.                                                   CDirectorOwner    *aSupervisor)
  26. {
  27.  
  28.     CDialog            *itsDialog;
  29.     DialogTHndl        dlogTemplateHdl;
  30.     DialogTemplate    dt;
  31.  
  32.     inherited::IDialogDirector (aSupervisor);
  33.     hasBegun = FALSE;
  34.  
  35.     itsDialog = new CDialog;
  36.     itsWindow = itsDialog;
  37.  
  38.     dlogTemplateHdl = (DialogTHndl) GetResource( 'DLOG', dialogID);
  39.     FailNILRes(dlogTemplateHdl);
  40.     dt = **dlogTemplateHdl;
  41.  
  42. // make a floating window iff procID = 3200, i.e. WDEF ID = 200
  43.     itsDialog->INewWindow (&dt.boundsRect, FALSE, dt.procID, (dt.procID==3200),
  44.                           dt.goAwayFlag, gDesktop, this);
  45.     itsDialog->IDialogX();
  46.  
  47.     itsDialog->SetTitle(dt.title);
  48.  
  49. } /* IAMDialogDirector */
  50.  
  51. /******************************************************************************
  52.  BeginDialog
  53.  
  54.      Set hasBegun true.
  55.     This is used to support modeless dialogs which may not be visible when created.
  56.     We create all modeless dialogs at App initialization time. We don't call BeginDialog
  57.     because that would make the dialog visible. If the dialog has its visible bit set, its
  58.     window will be Selected, which through a sequence of events will eventually call
  59.     ActivateWind. If it sees that BeginDialog has not been called then it calls it.
  60.     (Are there enough “it”s in the previous sentence?)
  61.  
  62.  ******************************************************************************/
  63. void    CAMDialogDirector::BeginDialog    (void)
  64. {
  65.     inherited::BeginDialog ();
  66.     hasBegun = TRUE;
  67.  
  68. } /* BeginDialog */
  69.  
  70. /******************************************************************************
  71.  ActivateWind
  72.  
  73.     Window owned by this Director has been activated
  74.     If BeginDialog has not been called, then call it now.
  75.  
  76.  ******************************************************************************/
  77. void    CAMDialogDirector::ActivateWind    (CWindow    *theWindow)
  78. {
  79.     if (!hasBegun) {
  80.         BeginDialog ();
  81.     }
  82.     inherited::ActivateWind (theWindow);
  83. } /* ActivateWind */
  84.  
  85. /******************************************************************************
  86.  CloseWind
  87.  
  88.  ******************************************************************************/
  89. void    CAMDialogDirector::CloseWind    (CWindow    *theWindow)
  90. {
  91.     theWindow->Hide ();
  92. } /* CloseWind */
  93.  
  94.  
  95. /******************************************************************************
  96.  DoCommand
  97.  
  98.  ******************************************************************************/
  99. void    CAMDialogDirector::DoCommand    (long        theCommand)
  100. {
  101.     switch (theCommand) {
  102.         case cmdClose:
  103.                 CloseWind (itsWindow);
  104.             break;
  105.         default:
  106.                 inherited::DoCommand (theCommand);
  107.             break;
  108.     } /* switch */
  109.  
  110. } /* DoCommand */
  111.  
  112. /* CAMDialogDirector */
  113.